<!DOCTYPE html>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>商家管理</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <link rel="stylesheet" href="/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="/plugins/adminLTE/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="/css/style.css">
	<script src="/plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="/plugins/bootstrap/js/bootstrap.min.js"></script>
    
</head>

<body class="hold-transition skin-red sidebar-mini"  >
  <!-- .box-body -->
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title">商家管理</h3>
                    </div>

                    <div class="box-body">
						<button type="button" class="btn btn-default" title="刷新" onclick="window.location.reload();"><i class="fa fa-refresh"></i> 刷新</button>

						<!-- 数据表格 -->
                        <div class="table-box">

                            <!--工具栏-->
                            
                            <div class="box-tools pull-right">
                                <div class="has-feedback">
							        公司名称：<input  type="text" id="aq">
									店铺名称： <input  type="text" id="sw">
									状态：
									<select id="stu">
										<option value="">全部</option>
										<option value="0">待审核</option>
										<option value="1">已审核</option>
										<option value="2">审核未通过</option>
										<option value="3">冻结</option>
									</select>
									<button class="btn btn-default" onclick="shenhe()">查询</button>
                                </div>
                            </div>
                            <!--工具栏/-->

			                  <!--数据列表-->
			                  <table id="dataList" class="table table-bordered table-striped table-hover dataTable">
			                      <thead>
			                          <tr>
			                              <th class="" style="padding-right:0px">
			                                  <input id="selall" type="checkbox" class="icheckbox_square-blue">
			                              </th> 
										  <th class="sorting_asc">商家ID</th>
									      <th class="sorting">公司名称</th>
									      <th class="sorting">店铺名称</th>
									      <th class="sorting">联系人姓名</th>
									      <th class="sorting">公司电话</th>
									      <th class="sorting">状态</th>
					                      <th class="text-center">操作</th>
			                          </tr>
			                      </thead>
			                      <tbody id="shenh">

			                      </tbody>
			                  </table>
			                  <!--数据列表/-->                        
                        </div>
                        <!-- 数据表格 /-->
                     </div>
                    <!-- /.box-body -->
<!-- 商家详情 -->
<div class="modal fade" id="sellerModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg" >
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
			<h3 id="myModalLabel">商家详情</h3>
		</div>
		<div class="modal-body">							
			
			 <ul class="nav nav-tabs">
			  <li class="active"><a href="#home" data-toggle="tab">基本信息</a></li>
			  <li><a href="#linkman" data-toggle="tab">联系人</a></li>
			  <li><a href="#certificate" data-toggle="tab">证件</a></li>
			  <li><a href="#ceo" data-toggle="tab">法定代表人</a></li>
			  <li><a href="#bank" data-toggle="tab">开户行</a></li>
			</ul>							
			
			<!-- 选项卡开始 -->         
		    <div id="myTabContent" class="tab-content">
			    <div class="tab-pane active in" id="home">
			      <br>
			      <table class="table table-bordered table-striped"  width="800px">
					  <input type="hidden" id="one">
			      	<tr>
						<input type="text" id="w">
			      		<td>公司名称</td>
			      		<td><input type="text" id="a" readonly="readonly"></td>
			      	</tr>
			      	<tr>
			      		<td>公司手机</td>
			      		<td><input type="text" id="b" readonly="readonly"></td>
			      	</tr>
			      	<tr>
			      		<td>公司电话</td>
			      		<td><input type="text" id="c" readonly="readonly"></td>
			      	</tr>
			      	<tr>
			      		<td>公司详细地址</td>
			      		<td><input type="text" id="d" readonly="readonly"></td>
			      	</tr>
			      </table>			      
      			</div>	
			    <div class="tab-pane fade" id="linkman">
			    	<br>
					<table class="table table-bordered table-striped" >
			      	<tr>
			      		<td>联系人姓名</td>
			      		<td><input type="text" id="e" readonly="readonly"></td>
			      	</tr>
			      	<tr>
			      		<td>联系人QQ</td>
			      		<td><input type="text" id="f" readonly="readonly"></td>
			      	</tr>
			      	<tr>
			      		<td>联系人手机</td>
			      		<td><input type="text" id="g" readonly="readonly"></td>
			      	</tr>
			      	<tr>
			      		<td>联系人E-Mail</td>
			      		<td><input type="text" id="h" readonly="readonly"></td>
			      	</tr>
			      </table>
			    </div>
			    <div class="tab-pane fade" id="certificate">
					<br>
					<table class="table table-bordered table-striped" >
				      	<tr>
				      		<td>营业执照号</td>
				      		<td><input type="text" id="i" readonly="readonly"></td>
				      	</tr>
				      	<tr>
				      		<td>税务登记证号</td>
				      		<td><input type="text" id="j" readonly="readonly"></td>
				      	</tr>
				      	<tr>
				      		<td>组织机构代码证号</td>
				      		<td><input type="text" id="k" readonly="readonly"></td>
				      	</tr>				      	
			     	</table>
			    </div>
			    <div class="tab-pane fade" id="ceo">
					<br>
					<table class="table table-bordered table-striped" >
				      	<tr>
				      		<td>法定代表人</td>
				      		<td><input type="text" id="l" readonly="readonly"></td>
				      	</tr>
				      	<tr>
				      		<td>法定代表人身份证号</td>
				      		<td><input type="text" id="m" readonly="readonly"></td>
				      	</tr>					   			      	
			     	</table>
			    </div>
			    <div class="tab-pane fade" id="bank">
					<br>
					<table class="table table-bordered table-striped" >
				      	<tr>
				      		<td>开户行名称</td>
				      		<td><input type="text" id="n" readonly="readonly"></td>
				      	</tr>
				      	<tr>
				      		<td>开户行支行</td>
				      		<td><input type="text" id="o" readonly="readonly"></td>
				      	</tr>		
				      	<tr>
				      		<td>登录名</td>
				      		<td><input type="text" id="p" readonly="readonly"></td>
				      	</tr>			   			      	
			     	</table>
<!--					密码-->
					<input type="hidden" id="q">
<!--					-->
					<input type="hidden" id="r">
					<input type="hidden" id="s">
					<input type="hidden" id="t">
					<input type="hidden" id="u">
					<input type="hidden" id="v">

					<input type="hidden" id="x">
			    </div>
  			    </div> 			
           <!-- 选项卡结束 -->          
			
		</div>
		<div class="modal-footer">						
			<button class="btn btn-success" data-dismiss="modal" onclick="update(1)" aria-hidden="true">审核通过</button>
         	<button class="btn btn-danger"  data-dismiss="modal" onclick="update(2)"  aria-hidden="true">审核未通过</button>
            <button class="btn btn-danger" data-dismiss="modal" onclick="update(3)" aria-hidden="true">关闭商家</button>
			<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</button>
		</div>
	  </div>
	</div>
</div>


</body>
<script>

	$(function (){
		shenhe();
	})

	function shenhe(){
		var a = $("#aq").val();
		var b = $("#sw").val();
		var c = $("#stu").val();
		$.ajax({
			url:"/seller/select",
			type:"post",
			data:{name:a,nickName:b,stu:c},
			dataType:"json",
			async:false,
			success:function (reso){
				var set = reso.resout;
				var a = "";
				for (var i = 0; i < set.length; i++) {
					a += "<tr>"
					a += '<td><input type="checkbox"></td>'
					a += '<td>'+set[i].sellerId+'</td>'
					a += '<td>'+set[i].name+'</td>'
					a += '<td>'+set[i].nickName+'</td>'
					a += '<td>'+set[i].linkmanName+'</td>'
					a += '<td>'+set[i].telephone+'</td>'
					if(set[i].status === '0'){
						a +=  "<td><span>待审核</span></td>";
					}else if(set[i].status === '1'){
						a +=  "<td><span>审核通过</span></td>";
					}else if(set[i].status === '2'){
						a +=  "<td><span>审核不通过</span></td>";
					}else if(set[i].status === '3'){
						a +=  "<td><span>账户以封</span></td>";
					}
					a += '<td className="text-center">'
					a += '<button type="button" className="btn bg-olive btn-xs" data-toggle="modal" data-target="#sellerModal" onclick="toupdate(\''+set[i].sellerId+'\')">修改</button>'
					a += '</td>'
					a += '</tr>'
				}
				$("#shenh").html(a);
			},
			error:function (){
				alert("审核查询系统错误")
			}
		})
	}

	function toupdate(id){
		$.ajax({
			url:"/seller/toupdate",
			type:"post",
			dataType:"json",
			data:{id:id},
			async:false,
			success:function (sost){
				var set = sost.resout;
				$("#a").val(set.name);
				$("#b").val(set.mobile);
				$("#c").val(set.telephone);
				$("#d").val(set.address);
				$("#e").val(set.linkmanName);
				$("#f").val(set.linkmanQq);
				$("#g").val(set.linkmanMobile);
				$("#h").val(set.linkmanEmail);
				$("#i").val(set.licenseNumber);
				$("#j").val(set.taxNumber);
				$("#k").val(set.orgNumber);
				$("#l").val(set.legalPerson);
				$("#m").val(set.legalPersonCardId);
				$("#n").val(set.bankUser);
				$("#o").val(set.bankName);
				$("#p").val(set.lname);


				$("#one").val(set.sellerId);
				$("#q").val(set.nickName);
				$("#y").val(set.password);
				$("#s").val(set.status);
				$("#t").val(set.addressDetail);
				$("#u").val(set.logoPic);
				$("#v").val(set.brief);
				$("#w").val(set.createTime);
				$("#x").val(set.salt);
			},
			error:function (){
				alert("数据回显系统错误")
			}
		})
	}

	function update(stid){
		var sid = $("#one").val();
		$.ajax({
			url:"/seller/update",
			type:"post",
			dataType:"json",
			data:{sellerId:sid,status:stid},
			async:false,
			success:function (set){
				if(set.code==1){
					alert(set.massager)
					window.location.reload();
				}else {
					window.location.reload();
				}
			},
			error:function (){
				alert("修改系统错误")
			}
		})

	}
</script>
</html>